<!--#include file="Ini.asp"-->
<!--#include file="../AspLib/Functions.asp"-->

<%
sDIVUL = RequesT("DIVUL") 
sREGIAO = RequesT("REGIAO") 
sLIVRO = Request("LIVRO") 
sTITULO = Request("TITULO") 


Response.expires = 0
MSQL="SELECT * FROM PNLD_2005_ESCOLAS_LIVROS "
MSQL=MSQL & " WHERE REGIAO='"& SREGIAO &"' AND OBJETO='" & sLIVRO  & "' AND DIVULGADOR='"& sDIVUL &"'"
MSQL=MSQL & " ORDER BY UF,MUNICIPIO,NOME"
'response.write  msql
'response.end
Set Conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 1500
Conn.Open sCo1, sCo2, sCo3
Set rs = Conn.Execute(MSql)			 

%>
<html>
<head>
<title><% = sTitle %></title>
<% = sBODY %>
<% = sCABECALHO %>VENDAS PNLD 2005 ESCOLAS 
<br><% = sFONT %></b><% = STITULO %></b>
  <table width='100%' border='1'<% =  sTABLE %>>
  <tr bgcolor='<% = COR_TARJA %>'>
  <td>Escola</td>
  <td align='right'>Qtd</td>
  </tr><%
  mcnt=0
  GQTD=0 
 Do while not rs.eof
    mcnt=mcnt+1
    GQTD=GQTD+rs("QTD")
    MEND=""
    IF NOT ISNULL(RS("ENDERECO")) THEN
       MEND=MEND & TRIM(RS("ENDERECO"))
    END IF
    IF NOT ISNULL(RS("NUMERO")) THEN
       IF LEN(TRIM(RS("NUMERO"))) > 1 THEN
          MEND=MEND & ","& TRIM(RS("NUMERO"))
       END IF
    END IF
    IF NOT ISNULL(RS("BAIRRO")) THEN
       IF LEN(TRIM(RS("BAIRRO"))) > 1 THEN
          MEND=MEND & "-" & TRIM(RS("BAIRRO"))
       END IF
    END IF
    %><TR>
     <td><a href='pnld2005_livro.asp?ESCOLA=<% = rs("CODESC") %>'>&nbsp;<% = rs("NOME") %></A></td>
    <td align='right'><% = FORMATNUMBER(rs("QTD"),0) %></td>

    </tr><%
    rs.MoveNext     	
  loop
  %><tr>
	  <td colspan='1'>Total <% = MCNT %> ITENS<br></td>
	  <td align='right'><B><% = FORMATNUMBER(GQTD,0)  %></td>
   </tr><%

rs.Close : Set rs = Nothing
Conn.Close : Set conn = Nothing 

%>
